package com.flash.BusinessParameters.mapper;

import com.flash.BusinessParameters.entity.Broker;
import com.flash.BusinessParameters.entity.BrokerDealSeat;
import com.flash.BusinessParameters.entity.DealSeat;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;


@Mapper
public interface DealSeatMapper{
    @Select("select * from (\n" +
            " select sb.*,rownum rn from ( select * from dealSeat s join broker br on s.brokerId = br.brokerId where 1=1 ${strWhere} ) sb )\n" +
            " where rn between #{page} and #{limit}")
    public List<BrokerDealSeat> selectDealSeatMap(Map map);
    @Select("select count(*) from dealSeat")
    int selectCountDealSeat();
    @Select("select * from dealSeat")
    List<DealSeat> selectDealSeat();

    @Insert("insert into broker values(#{brokerId},#{brokerName},#{brokerRemark})")
    int insertBroker(Broker broker);

    @Insert("insert into dealSeat values(#{seatId},#{brokerId},#{seatType},#{seatName},#{seatPlace},#{commission})")
    int insertDealSeat(DealSeat dealSeat);

    @Update("update broker set brokerName=#{brokerName},brokerRemark=#{brokerRemark} where brokerId=#{brokerId}")
    int updateBroker(Broker broker);

    @Update("update dealSeat set brokerId=#{brokerId},seatType=#{seatType},seatName=#{seatName},seatPlace=#{seatPlace},commission=#{commission} where seatId=#{seatId}")
    int updateDealSeat(DealSeat dealSeat);

    @Delete("delete from dealSeat where seatId=#{seatId}")
    int deleteDealSeat(String seatId);
}
